<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:ddl="livcos.org/ns/db/ddl"
	xmlns:f="livcos.org/ns/xslt/function"
	exclude-result-prefixes="ddl f">
	
	<xsl:import href="../../../../../../style/base.xsl"/>
	
	<xsl:param name="ref"/>
	<xsl:param name="id"/>
	
	<xsl:template match="/">
		<related>
			<xsl:variable name="tbl" select="doc($ref)/ddl:table"/>
			<xsl:apply-templates select="$tbl/ddl:ref"/>
			<xsl:apply-templates select="$tbl/ddl:key/ddl:referer"/>
		</related>
	</xsl:template>
	
	<xsl:template match="ddl:ref">
		<xsl:if test="@key-table != f:object-id(.)">
			<rel ref="{@key-table}"/>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="ddl:referer">
		<xsl:if test="@ref-table != f:object-id(.)">
			<rel ref="{@ref-table}"/>
		</xsl:if>
	</xsl:template>
	
</xsl:stylesheet>
